//
//  XVView.m
//  整合
//
//  Created by  刘尚威 on 2017/3/3.
//  Copyright © 2017年  刘尚威. All rights reserved.
//

#import "XVView.h"

@implementation XVView


//创建底视图
+ (UIView *)ViewWithBackgroundColor:(UIColor *)backgroundColor
                      masksToBounds:(BOOL)masksToBounds
                       cornerRadius:(CGFloat)cornerRadius
                        borderColor:(UIColor *)borderColor
                        borderWidth:(CGFloat)borderWidth
                          addToView:(UIView *)view
                              frame:(CGRect)frame
{
    UIView *newView = [[UIView alloc] initWithFrame:frame];
    
    //背景色
    if (backgroundColor == nil) {
        newView.backgroundColor = [UIColor clearColor];
    }
    else {
        newView.backgroundColor = backgroundColor;
    }
    
    //超出边框是否消失
    newView.layer.masksToBounds = masksToBounds;
    
    //边框角的弧度
    newView.layer.cornerRadius = cornerRadius;
    
    //边框的颜色
    if (borderColor == nil) {
        newView.layer.borderColor = [UIColor clearColor].CGColor;
    }
    else {
        newView.layer.borderColor = borderColor.CGColor;
    }
    
    //边框的宽度
    newView.layer.borderWidth = borderWidth;
    
    if (view != nil) {
        [view addSubview:newView];
    }
    
    return newView;
}


//创建分割线
+ (UIView *)createThreadWithbackgroundColor:(UIColor *)backgroundColor
                                  addToView:(UIView *)view
                                      frame:(CGRect)frame
{
    UIView *newView = [[UIView alloc] initWithFrame:frame];
    
    //背景色
    if (backgroundColor == nil) {
        newView.backgroundColor = [UIColor blackColor];
    }
    else {
        newView.backgroundColor = backgroundColor;
    }
    
    if (view != nil) {
        [view addSubview:newView];
    }
    
    return newView;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
